Imports System.Data.SqlClient
Imports System.Data
Imports CAPA_Entidad
Imports CAPA_Utilitarios
Public Class DocumentoAlmacenRelacionDatos

    'Se crea una instancia unica para las conexiones
    Dim conex As Conexion = Conexion.getInstance()

    Sub registrarDocumentoAlmacenRelacion(ByVal ciaS As String, ByVal sucS As String, ByVal tdoS As String, ByVal dcaS As String, ByVal codDADPUSalida As Integer, ByVal ciaI As String, ByVal sucI As String, ByVal tdoI As String, ByVal dcaI As String, ByVal codDADPUIngreso As Integer)
        Dim valor As Boolean = False
        Dim con As SqlConnection = conex.obtenerConexion()

        Try
            con.Open()

            Dim query As String = "INSERT INTO Documento_Almacen_Relacion " & _
                                  "(CIA_Salida,SUC_Codigo_Salida,TDOC_Codigo_Salida,DCA_Codigo_Salida,DADPU_CodigoSal,CIA_Ingreso,SUC_Codigo_Ingreso,TDOC_Codigo_Ingreso,DCA_Codigo_Ingreso,DADPU_CodigoIng,DAR_Activo) " & _
                                  "VALUES(@CIA_S,@SUC_S,@TDO_S,@DCA_S,@dadpuCodSal,@CIA_I,@SUC_I,@TDO_I,@DCA_I,@dadpuCodIng,'1')"

            Dim comando As New SqlCommand(query, con)
            With comando
                .Parameters.AddWithValue("@CIA_S", ciaS)
                .Parameters.AddWithValue("@SUC_S", sucS)
                .Parameters.AddWithValue("@TDO_S", tdoS)
                .Parameters.AddWithValue("@DCA_S", dcaS)
                .Parameters.AddWithValue("@dadpuCodSal", codDADPUSalida)
                .Parameters.AddWithValue("@CIA_I", ciaI)
                .Parameters.AddWithValue("@SUC_I", sucI)
                .Parameters.AddWithValue("@TDO_I", tdoI)
                .Parameters.AddWithValue("@DCA_I", dcaI)
                .Parameters.AddWithValue("@dadpuCodIng", codDADPUIngreso)
                .ExecuteNonQuery()
            End With

            valor = True
        Catch ex As Exception
            valor = False
        Finally
            con.Close()
        End Try
    End Sub

End Class
